
cc.Class({
    extends: cc.Component,

    properties: {
        BgSix:{
            default:null,
            type:cc.Node,
        },

        BgTwo:{
            default:null,
            type:cc.Node
        },

        btnSelectEnable:{
            default:null,
            type:cc.Node
        },

        btnSelectDisable:{
            default:null,
            type:cc.Node,
        },

        levelSelector:{
            default:null,
            type:cc.Node
        }
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        this._peopleCount = 0
        this._gameType = ""
        this._gameLevel = 0
        this._gameRound = 0     //deal game's round
    },

    initPeopleSelector(lobbyMgr,gameType){
        this.lobbyMgr = lobbyMgr
        this._gemeType = gameType
    },

    setPeopleCount(count){
        this._peopleCount = count
    },

    setGameType(type){
        this._gameType = type
    },

    setGameRound(round){
        this._gameRound = round
    },

    start () {

    },

    // update (dt) {},

    closePeopleSelector:function (event) {
        this._peopleCount = 0
        this.node.active = false
        this.BgTwo.active = false
        this.BgSix.active = false
        this.unlightSelectButton()
    },

    lightSelectButton:function (event) {
        this.btnSelectEnable.active = true
        this.btnSelectDisable.active = false
    },

    unlightSelectButton:function (event) {
        this.btnSelectEnable.active = false
        this.btnSelectDisable.active = true
    },

    onCountBtnClicked:function (event) {
        let btnName = event.target.name
        if(btnName === "BtnSix"){
            this._peopleCount = cc.gg.enumConfig.RoomMode.BASE_VALUE_6
            this.BgTwo.active = false
            this.BgSix.active = true
            this.lightSelectButton()
        }else if(btnName === "BtnTwo"){
            this._peopleCount = cc.gg.enumConfig.RoomMode.BASE_VALUE_2
            this.BgTwo.active = true
            this.BgSix.active = false
            this.lightSelectButton()
        }
    },

    onSelectButtonClicked:function (event) {
        let peopleCount = this._peopleCount
        let gameRound = this._gameRound
        let gameType = this._gemeType

        this.levelSelector.active = true
        this.levelSelector.getComponent("LevelSelector").initLevelSelector(this.lobbyMgr,gameType,peopleCount,gameRound)
    },
});
